package com.sgb.member.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;

import com.sgb.member.MemberConfig;
import com.sgb.member.R;
import com.sgb.member.di.DaggerMemberComponent;
import com.sgb.member.di.MemberModule;
import com.sgb.member.ui.fragment.CustomerApplicationFragment;
import com.sgb.member.ui.fragment.PersonAuditFragment;
import com.sgb.member.view_model.MemberAuditModel;
import com.swgk.core.base.AppActivity;
import com.swgk.core.base.di.AppComponent;
import com.swgk.core.recyclerview.adapter.SlidingFragmentPagerAdapter;

import java.util.ArrayList;

import javax.inject.Inject;

/**
 * 会员审核
 */
public class MemberAuditActivity extends AppActivity {

    private final String[] titles = {"会员申请", "会员邀请"};
    @Inject
    MemberAuditModel modelView;

    public static void start(Context context) {
        Intent intent = new Intent(context, MemberAuditActivity.class);
        context.startActivity(intent);
    }


    @Override
    protected void setupActivityComponent(AppComponent appComponent) {
        DaggerMemberComponent.builder()
                .appComponent(appComponent)
                .memberModule(new MemberModule(this))
                .build()
                .inject(this);
    }

    @Override
    protected void initView() {
        com.sgb.member.databinding.ActivityMemberAuditBinding mMemberAudit = DataBindingUtil.setContentView(this, R.layout.activity_member_audit);
        mMemberAudit.title.titleView.setText("会员审核");
        mMemberAudit.title.ivBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        ArrayList<Fragment> mFragments = new ArrayList<Fragment>();
        if (MemberConfig.getInstance().getComType() == MemberConfig.WEBSITE_FOR_PERSONAL) {
            mFragments.add(PersonAuditFragment.newInstance(1));
        } else {
            mFragments.add(CustomerApplicationFragment.newInstance());
        }
        SlidingFragmentPagerAdapter mAdapetr = new SlidingFragmentPagerAdapter(getSupportFragmentManager(), mFragments, titles);
        mMemberAudit.viewpager.setAdapter(mAdapetr);
        mMemberAudit.tablayout.setVisibility(View.GONE);
    }
}
